<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script>
</head>
<body>
    <h2>axios</h2>
    <button>GET请求</button>
    <button>POST请求</button>
    <button>Ajax请求</button>

    <script>
        $("button").eq(0).click(function(){
            axios.get('http://127.0.0.1:8085/axios-server',{
                params:{ 
                    a:500,
                    b:600
                },
                headers:{ 
                    name:'su'
                }
            }).then(value=>{
                console.log(value.data)
            })
        })
        $('button').eq(1).click(function(){
            axios.post('http://127.0.0.1:8085/axios-server',{
                username:'sulaing',
                password:'12457844'
            },{
                params:{ 
                    a:300,
                    b:400
                },
                headers:{ 
                    name:'su'
                }
            }).then(value=>{
                console.log(value);
            })
        })
        $('button').click(function(){
            axios({
                // 请求类型
                methods:"GET",
                url:'http://127.0.0.1:8085/axios-server',
                // url参数
                params:{ 
                    a:900,
                    b:700
                },
                // 响应体
                data:{ 
                    username:"su",
                    password:"15466"
                },
                headers:{ 
                    name:"liang"
                }
            }).then(value=>{
                console.log(value);
            })
        })
    </script>
</body>
</html>